# Maintainer: Jakob Meier <comcloudway@ccw.icu>
# Contributor: Jakob Meier <comcloudway@ccw.icu>
# Contributor: Grigory Kirillov <txgk@bk.ru>
pkgname=maxima
pkgver=5.47.0
pkgrel=4
pkgdesc="Sophisticated computer algebra system"
url="http://maxima.sourceforge.net"
# ppc64le, s390x, riscv64: blocked by sbcl
# arm*, x86: not useful on 32-bit
# aarch64: fails to build
arch="x86_64"
license="GPL-2.0-or-later"
depends="texinfo shared-mime-info sbcl"
makedepends="python3 perl gmp-dev"
checkdepends="gnuplot"
subpackages="
	$pkgname-doc
	$pkgname-doc-extra
	$pkgname-bash-completion
	$pkgname-emacs
	"
source="maxima-$pkgver.tar.gz::https://sourceforge.net/projects/maxima/files/Maxima-source/$pkgver-source/maxima-$pkgver.tar.gz/download"
options="!check" # take hours

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--libexecdir=/usr/lib \
		--localstatedir=/var \
		--enable-sbcl \
		--with-default-lisp=sbcl
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	# remove unused files
	find "$pkgdir" -type d -iname tests -exec rm -r {} \+
}

extra() {
	pkgdesc="$pkgdesc (extra html documentation + demos)"

	amove usr/share/$pkgname/$pkgver/doc
	amove usr/share/$pkgname/$pkgver/demo
}

emacs() {
	depends="$pkgname=$pkgver-r$pkgrel"
	install_if="$pkgname=$pkgver-r$pkgrel emacs"
	pkgdesc="Emacs plugins for $pkgname"

	amove usr/share/emacs
}

sha512sums="
953b98336eb086069edaa917981372450ce165dedd7a7b39b181d3f2d8b089551eea943e0084148eaa3ded395dcba9135509d3d11d9132ab7a3ad8bb800d3a11  maxima-5.47.0.tar.gz
"
